-
Notifications
You must be signed in to change notification settings - Fork 525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: auto set GOMEMLIMIT when memory is limited #14882
Conversation
use automemlimit lib to set memory limit run check every 30s
This pull request does not have a backport label. Could you fix it @kruskall? 🙏
|
|
@@ -348,6 +350,11 @@ func (b *Beat) Run(ctx context.Context) error { | |||
return adjustMaxProcs(ctx, 30*time.Second, logger) | |||
}) | |||
|
|||
slogger := slog.New(zapslog.NewHandler(logger.Core())) | |||
if err := adjustMemlimit(1*time.Second, slogger); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this in the first review, but isn't a 1 second refresh interval a bit on the aggressive side? I haven't delved into the details of the library, but it seems like a waste of CPU cycles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aaah, this was there for testing. It should be 30s like the max procs check 😭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Motivation/summary
By default memlimit uses all the memory available on the host but if cgroups are used and the process is being limited we want to use the correct max memory.
Use automemlimit lib to set memory limit
Run check every 30s
Similar approach as automaxprocs
Test has to be performed manually (see below) because we can't really restrict the process memory :(
Checklist
For functional changes, consider:
How to test these changes
make apm-server
docker run -it -v ./:/apm-server --memory=4096m golang
Related issues
Closes #14475